const sqlite3 = require('sqlite3').verbose();
const path = require('path');

const dbPath = path.join(__dirname, 'data', 'pph.sqlite');
const db = new sqlite3.Database(dbPath);

console.log('🏗️ 检查pph_records表是否有目标值字段...');

db.all("PRAGMA table_info(pph_records)", (err, columns) => {
    if (err) {
        console.error('❌ 查询失败:', err);
    } else {
        console.log(`\n📋 pph_records表字段列表 (共${columns.length}个):`);
        columns.forEach(col => {
            console.log(`  ${col.cid}: ${col.name} (${col.type})`);
        });
        
        // 检查关键字段
        const targetFields = ['target_pph', 'estimate_pph', 'efficiency_rate', 'target_record_date'];
        console.log('\n🎯 目标值相关字段检查:');
        targetFields.forEach(field => {
            const exists = columns.find(col => col.name === field);
            console.log(`  ${field}: ${exists ? '✅ 存在' : '❌ 不存在'}`);
        });
    }
    db.close();
});
